package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.ScenicSpot;
import cn.wolfcode.luowowo.article.domain.SpotTag;
import cn.wolfcode.luowowo.article.mapper.ScenicSpotMapper;
import cn.wolfcode.luowowo.article.mapper.SpotTagMapper;
import cn.wolfcode.luowowo.article.query.SpotQuery;
import cn.wolfcode.luowowo.article.service.IScenicSpotService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service
public class ScenicSpotServiceImpl implements IScenicSpotService {

    @Autowired
    private ScenicSpotMapper scenicSpotMapper;

    @Autowired
    private SpotTagMapper spotTagMapper;

    @Override
    public ScenicSpot get(Long id) {
        return scenicSpotMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<ScenicSpot> list() {
        return scenicSpotMapper.selectAll();
    }

    @Override
    public List<ScenicSpot> queryTop5(Long destId) {
        return scenicSpotMapper.selectTop5(destId);
    }

    @Override
    public List<ScenicSpot> hotspot(Long destId) {
        return scenicSpotMapper.hotspot10(destId);
    }

    @Override
    public PageInfo query(SpotQuery qo) {
        PageHelper.startPage( qo.getCurrentPage(), qo.getPageSize() );
        List<ScenicSpot> list = scenicSpotMapper.selectForList(qo);
        return new PageInfo(list);
    }

    @Override
    public List<SpotTag> tagsAll() {
        return spotTagMapper.selectAll();
    }

    @Override
    public List<ScenicSpot> getChild(Long id) {
        return scenicSpotMapper.selectByParentId(id);
    }

    @Override
    public List<ScenicSpot> queryForTop3BySpotcomment() {

        return scenicSpotMapper.queryForTop3BySpotcomment();
    }

    @Override
    public List<ScenicSpot> queryForList(Long uid) {
        return scenicSpotMapper.queryForList(uid);
    }

    @Override
    public int queryForCount(Long uid) {
        return scenicSpotMapper.queryForCount(uid);
    }

    @Override
    public List<ScenicSpot> queryForTop5(Long uid) {
        return scenicSpotMapper.queryForTop5(uid);
    }
}
